//----------------------------------------------------------------------------------------------------
//         ATMEL Microcontroller Software Support  -  ROUSSET  -
//----------------------------------------------------------------------------------------------------
// The software is delivered "AS IS" without warranty or condition of any
// kind, either express, implied or statutory. This includes without
// limitation any warranty or condition with respect to merchantability or
// fitness for any particular purpose, or against the infringements of
// intellectual property rights of others.
//----------------------------------------------------------------------------------------------------
// File Name: 	Board.h
// Object: 		AT91SAM7S Evaluation Board Features Definition File.
//
// Creation:	JPP   16/June/2004
//----------------------------------------------------------------------------------------------------   
#ifndef Board_h
#define Board_h

#include "AT91SAM7X256.h"
#define __inline inline

#define true	-1
#define false	0

#if 0
//----------------------------------------------- 
// SAM7Board Memories Definition   
//-----------------------------------------------  
// The AT91SAM7X256 embeds a 64-Kbyte SRAM bank, and 256 K-Byte Flash

#define  INT_SRAM		0x00200000
#define  INT_SRAM_REMAP		0x00000000

#define  INT_FLASH		0x00000000
#define  INT_FLASH_REMAP	0x01000000

#define  FLASH_PAGE_NB		512
#define  FLASH_PAGE_SIZE	128
#endif

//------------------------  
// Leds Definition   
//------------------------  
#define LED1			AT91C_PIO_PA12
#define LED2			AT91C_PIO_PA29
#define NB_LED			2
#define LED_MASK		(LED1|LED2)

//------------------------  
// I2C   
//------------------------  
#define I2C_SDA			AT91C_PA10_TWD
#define I2C_SCL			AT91C_PA11_TWCK

//------------------------  
// Pressure sensor   
//------------------------  
#define HP03D_XCLR		AT91C_PIO_PA19
#define HP03D_MCLK		AT91C_PB25_TIOA1

//-------------------------  
// GPS USART 
//-------------------------  
#define GPS_RXD			AT91C_PA5_RXD1
#define GPS_TXD			AT91C_PA6_TXD1
#define GPS_PORT		1
#define GPS_BAUD        19200

//-------------------------  
// Receiver PWM inputs   
//-------------------------  

#define RECEIVER1_INPUT		AT91C_PIO_PA19
#define RECEIVER2_INPUT		AT91C_PIO_PA20
#define RECEIVER3_INPUT		AT91C_PIO_PA21
#define RECEIVER4_INPUT		AT91C_PIO_PA22
#define RECEIVER5_INPUT		AT91C_PIO_PA23
#define RECEIVER_MASK (RECEIVER1_INPUT | RECEIVER2_INPUT | RECEIVER3_INPUT | RECEIVER4_INPUT | RECEIVER5_INPUT)

#define NUM_RECEIVER_INPUTS 5

//-------------------------  
// Servo outputs   
//-------------------------  
#define SERVO1_OUTPUT		AT91C_PIO_PA24
#define SERVO2_OUTPUT		AT91C_PIO_PA25
#define SERVO3_OUTPUT		AT91C_PIO_PA26
#define SERVO4_OUTPUT		AT91C_PIO_PA27
#define SERVO5_OUTPUT		AT91C_PIO_PA28

#define SERVO_MASK (SERVO1_OUTPUT | SERVO2_OUTPUT | SERVO3_OUTPUT | SERVO4_OUTPUT | SERVO5_OUTPUT)

#define NUM_SERVO_OUTPUTS 5

//-------------------------  
// Leveler (analog inputs)
//-------------------------  
#define LEVELER_UPDOWN					// AD5
#define LEVELER_A						// AD6
#define LEVELER_B						// AD7

#if 0
//-------------------------  
// IMU
//-------------------------  
#define GYRO_PITCH		AT91C_PIO_PA19			// AD2
#define GYRO_ROLL		AT91C_PIO_PA20			// AD3
#define GYRO_YAW						// AD4
#define ACCEL_X							// AD5
#define ACCEL_Y							// AD6
#define ACCEL_Z							// AD7
#endif

#define NUM_ANALOG_INPUTS 8

//-------------------------  
// USB detect
//-------------------------  
//#define USB_DETECT		AT91C_PIO_PA31
// no usb detect for now
#define USB_DETECT          0

//-------------------------  
// Optional serial radio USART 
//-------------------------  
#define SRADIO_RXD		AT91C_PA0_RXD0
#define SRADIO_TXD		AT91C_PA1_TXD0
#define SRADIO_PORT		0
#define SRADIO_BAUD     115200
#define NUM_SERIAL_CHANNELS	2

//-------------------------  
// microSD card (via SPI port 0)
//-------------------------  
#define MICROSD_MISO	AT91C_PA16_MISO0
#define MICROSD_MOSI	AT91C_PA17_MOSI0
#define MICROSD_SPCK	AT91C_PA18_SPCK0
#define MICROSD_CS		AT91C_PA13_NPCS0
#define MICROSD_CD		AT91C_PIO_PA14

//--------------  
// Master Clock   
//--------------  
#define EXT_OC		18432000						// Exetrnal ocilator MAINCK
#define MCK			47923200						// MCK (PLLRC div by 2)

//------------------------------------------------------------------------------
/// \page "SAM7S-EK - USB device"
/// This page lists constants describing several characteristics (controller
/// type, D+ pull-up type, etc.) of the USB device controller of the chip/board.
/// 
/// !Constants
/// - BOARD_USB_UDP
/// - BOARD_USB_PULLUP_EXTERNAL
/// - BOARD_USB_NUMENDPOINTS
/// - BOARD_USB_ENDPOINTS_MAXPACKETSIZE
/// - BOARD_USB_ENDPOINTS_BANKS

/// Chip has a UDP controller.
#define BOARD_USB_UDP

/// Indicates the D+ pull-up is internal.
#define BOARD_USB_PULLUP_ALWAYSON

/// Number of endpoints in the USB controller.
#define BOARD_USB_NUMENDPOINTS                  4

/// Returns the maximum packet size of the given endpoint.
#define BOARD_USB_ENDPOINTS_MAXPACKETSIZE(i)    ((i == 0) ? 8 : 64)
#define BOARD_USB_ENDPOINTS_MAXPACKETSIZE_FS    64

/// Returns the number of FIFO banks for the given endpoint.
#define BOARD_USB_ENDPOINTS_BANKS(i)            (((i == 0) || (i == 3)) ? 1 : 2)

/// USB attributes configuration descriptor (bus or self powered, remote wakeup)
#define BOARD_USB_BMATTRIBUTES                  USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP
//#define BOARD_USB_BMATTRIBUTES                  USBConfigurationDescriptor_BUSPOWERED_NORWAKEUP
//#define BOARD_USB_BMATTRIBUTES                  USBConfigurationDescriptor_SELFPOWERED_RWAKEUP
//------------------------------------------------------------------------------

#endif   // Board_h     
